package com.lanqiao.testwork;

public class Test20 {

	public static void main(String[] args) {
		test();
	}

	/**
	 * 计算2/1 + 3/2 + 5/3 + 8/4...的前二十项之和
	 */
	private static void test() {
		int upNum1 = 2;
		int upNum2 = 3;
		double doNum1 = 1;
		double doNum2 = 2;
		double num = upNum1 / doNum1 + upNum2 / doNum2;
		for (int i = 3; i <= 20; i++) {
			upNum2 = upNum1 + upNum2;
			upNum1 = upNum2 - upNum1;
			doNum2++;
			num += upNum2 / doNum2;
		}
		System.out.println(num);

	}

}
